All Questions
13 questions
0votes
2answers
213views
How can I loop 2 methods together?
Question I am very new to Java and I am trying to learn as best as I can.The actual question of the problem I am trying to solve is in the picture above. Please do refer to the picture in case I am ...
1vote
1answer
110views
Getting inputs recursively for matrix gives index out of border exception
I should write a java program that contains giving values to a matrix and printing the values of a matrix recursively. I tried this code,but everytime I give the input it gives index out of border ...
0votes
1answer
1kviews
Convert a flat list into tree structure having the depth of each node
I'm using java and I have the need to convert a flat Set<Object> into a Set of Object which can contains others list of objects recursively. I receive this JSON data from the react front-end: [ ...
1vote
2answers
141views
Java dynamic nested loops
I have a map which contains variable length string list. e.g Map<String, List<String> map = new HashMap<>(); map.put("key", "key1, key2); map.put("name", "name1, name2, name3"); map....
0votes
4answers
3kviews
Replacing nested FOR loops using recursion or any other solution
<?xml version="1.0"?> <Event> <Country>England</Country> <City>London</City> <City>Liverpool</City> <Code>DWW</Code> <ID>...
0votes
1answer
126views
How can I convert these nested loops into recursive form?
I'm having trouble with trying to generate all possible combinations of a n*n grid. The code below shows how I would go about it using nested loops and a 2*2 grid. However, if I wanted to do the same ...
-1votes
1answer
102views
Generate all unique 1-1 mappings between two lists of strings (Java) [duplicate]
How to you generate a set of all possible 1-1 mappings between two lists. I want each mapping to be unique, but am not too concerned about computation time (brute force is probably fine). Lists can be ...
3votes
1answer
1kviews
Series of nested loops without recursion
In Java, I have the following general code for integer d equal to 2, 3, 4, ..., dmax - up to a maximum number dmax : d < dmax (so this code is repeated for every value of d in that range): // d is ...
0votes
4answers
746views
Java: Combination of recursive loops which has different FOR loop inside; Output: FOR loops indexes
currently recursion is fresh & difficult topic for me, however I need to use it in one of my algorithms. Here is the challenge: I need a method where I specify number of recursions (number of ...
25votes
12answers
26kviews
Cartesian Product of a List of Lists
I have a problem that is really kind of a general programming question, but my implementation is in Java, so I will provide my examples that way I have a class like this: public class Foo { ...
3votes
5answers
5kviews
Turning a recursive function into a for loop?
Does every recursive function have an equivalent for loop? (Both achieve the same result). I have this recursive function: private static boolean recur(String word, int length) { if(length == 1 |...
2votes
7answers
381views
Is a concurrency approach a good idea for speeding a long iteration?
I have an app that does an iteration to create points on a graph over time. While I'm gathering data for each point across the x-axis I also must execute a recursive lookup which effectually means I ...
1vote
1answer
3kviews
Recursive function in java - N nested loops with changing indicies
Similar to this: Is there any way to do n-level nested loops in Java? I want to create a recursive function, which generates N nested loops, where the indicies depend on the depth of the loop. So ...